function filterBy(array, predicate) {
    var result = [];
    array.forEach(function (item) {
        if (predicate(item)) {
            result.push(item);
        }
    });
    return result;
}
var newArray = filterBy([1, 2, 3, 4, 5, 6], function (item) { return item > 3; });
console.log(newArray);
var newCity = filterBy(["合肥", "马鞍山", "攀枝花", "石家庄", "南京"], function (item) { return item.length > 2; });
console.log(newCity);
